<template>
  <div class="aui-card-list">
  <uni-list-query-card :queryShow="queryShow" @query-click="getDataList()" @click="(e)=>{this.queryShow=e}" @searchReset="searchReset()">
      <el-col :span="5">
        <el-form-item label="主题编号">
          <el-input v-model="dataForm.auditCode" placeholder="主题编号" clearable></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="5">
        <el-form-item label="状态">
          <el-select v-model="dataForm.auditStatus" placeholder="状态" clearable>
                <el-option v-for="template in statusItems" :key="template.val" :label="template.label"
                  :value="template.val"></el-option>
              </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="10">
      <el-form-item label="时间">
              <el-date-picker v-model="dataForm.bDate" placeholder="开始时间" type="date" style="width: 150px"
                value-format="yyyy-MM-dd"></el-date-picker>-
              <el-date-picker v-model="dataForm.eDate" placeholder="结束时间" type="date" style="width: 150px"
                value-format="yyyy-MM-dd"></el-date-picker>
            </el-form-item>
      </el-col>
  </uni-list-query-card>
    <el-card shadow="never" class="aui-card-list-body">
      <vxe-toolbar :setting="{immediate:true}">
        <template v-slot:tools>
          <el-button icon="el-icon-refresh" @click="getDataList()" circle></el-button>
          <el-dropdown trigger="click" style="padding-left: 5px;" placement="bottom">
            <el-button icon="el-icon-download" circle>
            </el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item icon="el-icon-bottom" @click.native="exportHandle(true)">导出当前页</el-dropdown-item>
              <el-dropdown-item icon="el-icon-download" @click.native="exportHandle()">全部导出
              </el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </vxe-toolbar>
      <div class="aui-card-list-body-table">
      <vxe-table ref="xTable" :loading="dataListLoading" class="vxe-table-element" auto-resize
        @select-change="dataListSelectionChangeHandleVex" @select-all="dataListSelectionAllChangeHandleVex"
        :data="dataList" max-height="auto">
        <vxe-table-column type="checkbox" align="center" width="60"></vxe-table-column>
        <vxe-table-column field="auditCode" title="主题编号" :width="120" align="center">
        </vxe-table-column>
        <vxe-table-column field="auditName" title="主题" align="center">
        </vxe-table-column>
        <vxe-table-column field="auditStatus" title="状态" :width="100" align="center">
          <template slot-scope="scope">
            <el-tag :type="scope.row.auditStatus===1?'success':'error'">{{ $getDataItem (statusItems,
              scope.row.auditStatus).label }}</el-tag>
          </template>
        </vxe-table-column>
        <vxe-table-column field="remark" title="结果说明">
        </vxe-table-column>
        <vxe-table-column field="auditParams" title="参数">
        </vxe-table-column>
        <vxe-table-column field="auditResult" title="JSON结果">
        </vxe-table-column>
        <vxe-table-column field="createDate" title="日志时间" width="150">
        </vxe-table-column>
        <vxe-table-column field="url" title="业务显示" width="70" align="center">
          <template slot-scope="scope">
            <el-button type="text" @click="open(scope.row)" v-if="scope.row.url">查看</el-button>
          </template>
        </vxe-table-column>
        <!-- <vxe-table-column title="handle" fixed="right" align="center">
          <template slot-scope="scope">
            <el-button v-if="$hasPermission('api:apiAuditLog:update')" type="text" size="small" icon="el-icon-edit"
              @click="addOrUpdateHandle(scope.row)">{{ $t('update') }}</el-button>
            <el-button v-if="$hasPermission('api:apiAuditLog:delete')" type="text" size="small" icon="el-icon-delete"
              @click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button>
          </template>
        </vxe-table-column> -->
      </vxe-table>
      <el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total"
        layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle">
      </el-pagination>
      </div>
    </el-card>
  </div>
</template>
<script>
import mixinViewModule from '@/mixins/view-module'
import URLUtil from '@/utils/url'
export default {
  mixins: [mixinViewModule],
  data () {
    return {
      searchShow: true,
      statusItems: [{ val: 1, label: '成功' }, { val: 0, label: '失败' }],
      mixinViewModuleOptions: {
        getDataListURL: '/api/apiAuditLog/page',
        getDataListIsPage: true,
        deleteURL: '/api/apiAuditLog',
        deleteIsBatch: true,
        exportURL: '/api/apiAuditLog/export'
      },
      dataForm: {
        auditCode: '',
        auditStatus: '',
        createDate: '',
        bDate: '',
        eDate: ''
      }
    }
  },
  components: {},
  methods: {
    open (row) {
      let res = URLUtil.fitUrl(row.url)
      // 打开路由
      var router = {
        name: 'apiAuditLog',
        id: row.id,
        oldName: 'apiAuditLog',
        path: res.url,
        title: '业务日志窗口 - ' + row.id
      }
      this.openNewTab(this.$router, router, res.params)
    },
    // 新增 / 修改
    addOrUpdateHandle (row) {
      let id
      if (row) {
        id = row.id
      }
      this.addOrUpdateVisible = true
      this.$nextTick(() => {
        this.$refs.addOrUpdate.dataForm.id = id
        this.$refs.addOrUpdate.init()
      })
    }
  }
}
</script>
